package com.yixun.qfbao.hander;

import com.yixun.qfbao.api.service.AreaService;
import com.yixun.qfbao.apidto.GetProvinceForOtherResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.xf.model.enums.ResultEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("GetProvinceForOtherHander")
public class GetProvinceForOtherHander extends CommonAbstractHander {
    private static Logger logger= LoggerFactory.getLogger(GetProvinceForOtherHander.class);
    @Autowired
    private AreaService areaService;

    @SuppressWarnings("rawtypes")
    @Override
    public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
        BaseResponseDTO<GetProvinceForOtherResDto> res = new BaseResponseDTO<GetProvinceForOtherResDto>();
        GetProvinceForOtherResDto resDto = new GetProvinceForOtherResDto();
        try {
            resDto = areaService.getProvinceForOther();
        } catch (Exception e) {
            logger.error("GetProvinceForOtherHander error: {}", e);
            resDto.setResult(ResultEnum.FAIL.getNo());
            resDto.setMessage("获取省份失败");
        }
        res.setResData(resDto);
        res.setResult(resDto.getResult());
        return res;
    }
}
